/*
 * GivenQBC.C
 *
 *  Created on: 2021年1月6日
 *      Author: liuxiao
 */



#include "GivenQBC.h"
#include "MathUtils.h"
registerMooseObject("TrilobitaApp", GivenQBC);
InputParameters
GivenQBC::validParams()
{
  InputParameters params = IntegratedBC::validParams();
  params.addParam<Real>("stefan_boltzmann_constant", 5.670367e-8, "The Stefan-Boltzmann constant.");
  params.addParam<Real>("q", 0, "The given heat flux except radiation");
  params.addParam<Real>(
      "Tinfinity", 0, "Temperature of the body in radiative heat transfer.");
  params.addParam<Real>("boundary_emissivity", 1, "Emissivity of the boundary.");
  params.addClassDescription("Boundary condition for radiative heat flux where radiative heat transfer is considered.");
  return params;
}

GivenQBC::GivenQBC(const InputParameters & parameters)
  : IntegratedBC(parameters),
	_q(getParam<Real>("q")),
    _sigma_stefan_boltzmann(getParam<Real>("stefan_boltzmann_constant")),
    _tinf(getParam<Real>("Tinfinity")),
    _eps_boundary(getParam<Real>("boundary_emissivity"))
{
}

Real
GivenQBC::computeQpResidual()
{
  Real T4 = MathUtils::pow(_u[_qp], 4);
  Real T4inf = MathUtils::pow(_tinf, 4);
  return -_test[_i][_qp] * (_q - _eps_boundary*_sigma_stefan_boltzmann *  (T4 - T4inf));
}

Real
GivenQBC::computeQpJacobian()
{
  Real T3 = MathUtils::pow(_u[_qp], 3);
  return 4 * _sigma_stefan_boltzmann * _test[_i][_qp] * _eps_boundary * T3 * _phi[_j][_qp];
}



